package com.zkthink.ceres.applet.pcSetting.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zkthink.base.R;
import com.zkthink.ceres.applet.pcSetting.domain.vo.PcSettingVo;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zkthink.ceres.applet.pcSetting.mapper.PcSettingMapper;
import com.zkthink.ceres.applet.pcSetting.domain.entry.PcSetting;
import com.zkthink.ceres.applet.pcSetting.service.PcSettingService;

import javax.annotation.Resource;

/**

@Author cmz
@Date 2024-05-14 9:27
*/
@Service
public class PcSettingServiceImpl extends ServiceImpl<PcSettingMapper, PcSetting> implements PcSettingService{

    @Resource
    private PcSettingMapper pcSettingMapper;
    @Override
    public R<PcSettingVo> selectOneNewSettingByType(Integer settingType) {
        QueryWrapper<PcSetting> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("setting_type",settingType);//对应类型的
        queryWrapper.orderByDesc("create_time");//最新的
        PcSetting pcSetting = pcSettingMapper.selectList(queryWrapper).get(0);
        PcSettingVo pcSettingVo = new PcSettingVo();
        BeanUtils.copyProperties(pcSetting,pcSettingVo);
        return R.success(pcSettingVo);
    }
}
